cmake_minimum_required(VERSION 3.10)
if (NOT ROOT_DIR)
    set(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../")
endif()
set(CURRENT_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/toolchain_common.cmake)

# 指定交叉编译工具链的根路径
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

# 设置arm-none-eabi编译工具链
set(CMAKE_C_COMPILER_FORCED TRUE)
set(CMAKE_CXX_COMPILER_FORCED TRUE)

if (NOT COMPILER_ROOT)
    set(COMPILER_ROOT ${ROOT_DIR}/buildtools/toolchains/gcc-arm-none-eabi-9-2020-q2-update)
endif()

# set find executable programs on the host system path
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_C_COMPILER "${COMPILER_ROOT}/bin/arm-none-eabi-gcc")
set(CMAKE_CXX_COMPILER "${COMPILER_ROOT}/bin/arm-none-eabi-g++")
set(CMAKE_ASM_COMPILER "${COMPILER_ROOT}/bin/arm-none-eabi-gcc")
set(CMAKE_AR           "${COMPILER_ROOT}/bin/arm-none-eabi-ar")
set(CMAKE_RANLIB       "${COMPILER_ROOT}/bin/arm-none-eabi-ranlib")
set(CMAKE_OBJCOPY      "${COMPILER_ROOT}/bin/arm-none-eabi-objcopy")
set(CMAKE_STRIP        "${COMPILER_ROOT}/bin/arm-none-eabi-strip")
set(CMAKE_LINKER       "${COMPILER_ROOT}/bin/arm-none-eabi-ld")

message(INFO " C compiler is ${CMAKE_C_COMPILER}")
message(INFO " CXX compiler is ${CMAKE_CXX_COMPILER}")